'           AreaCode()

    <Description("Kod obszaru lub pierwsze trzy cyfry numeru" & _
    "ubezpieczenia.")> _
    Property AreaCode() As String
      Get
        Return Me.txtAreaCode.Text
      End Get
      Set(ByVal Value As String)
        Me.txtAreaCode.Text = Value
      End Set
    End Property

    '           Exchange() 
    <Description("Numer centrali lub rodkowe dwie cyfry numeru" & _
    "ubezpieczenia .")> _
    Property Exchange() As String
      Get
        Return Me.txtExchange.Text
      End Get
      Set(ByVal Value As String)
        Me.txtExchange.Text = Value
      End Set
    End Property

    '           Number() 
    <Description("Ostatnie cztery cyfry numeru telefonu lub" & _
    "numeru ubezpieczenia.")> _
    Property Number() As String
      Get
        Return Me.txtNumber.Text
      End Get
      Set(ByVal Value As String)
        Me.txtNumber.Text = Value
      End Set
    End Property

    '           Complete()
    <Description("Cay numer telefonu lub numer ubezpieczenia.")> _
    Property Complete() As String
      Get
        If mBoxType = Selection.Phone Then
          mComplete = "(" & Me.txtAreaCode.Text & ") " & _
                          Me.txtExchange.Text & "-" & _
                          Me.txtNumber.Text()
        Else
          mComplete = Me.txtAreaCode.Text & "-" & _ 
                   Me.txtExchange.Text & "-" & Me.txtNumber.Text
        End If
        Return mComplete
      End Get
      Set(ByVal Value As String)
        Me.txtNumber.Text = Value
      End Set
    End Property


    '============ Metody klasy ============

    ' Te stae s wyznaczone ze stosunku szerokoci pola
    ' do szerokoci formantu. Moe to troch brzydkie, ale dziaa.
    Private Const TWODIGITS As Single = 0.19
    Private Const THREEDIGITS As Single = 0.238
    Private Const FOURDIGITS As Single = 0.286

    Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
      MyBase.OnFontChanged(e)  ' gdy zmienimy czcionk
      ResizeFieldBoxes()
    End Sub

    Private Sub PhoneSSNTextBox_Resize(ByVal sender As Object, _
                    ByVal e As System.EventArgs) _
                    Handles MyBase.Resize  ' gdy rozszerzymy cay formant
      ResizeFieldBoxes()
    End Sub

    Private Sub ResizeFieldBoxes()
      Dim ControlWidth As Integer = Me.ClientRectangle.Width
      Dim ControlHeight As Integer = Me.ClientRectangle.Height
      Dim TwoBox, ThreeBox, FourBox As Integer

      If ControlHeight < 24 Then    ' Ustaw minimaln wysoko formantu
        ControlHeight = 32
        Me.Height = 32
      End If

      If ControlWidth < 104 Then    'Ustaw minimaln szeroko formantu
        ControlWidth = 104
        Me.Width = ControlWidth
      End If

      TwoBox = ControlWidth * TWODIGITS   ' Ustaw wzgldny rozmiar 
      ThreeBox = ControlWidth * THREEDIGITS
      FourBox = ControlWidth * FOURDIGITS

      txtAreaCode.SetBounds(8, 8, ThreeBox, 0)

      If mBoxType = Selection.Phone Then
        txtExchange.SetBounds(ThreeBox + 8, 8, ThreeBox, 0)
        txtNumber.SetBounds(ThreeBox * 2 + 8, 8, FourBox, 0)
      Else
        txtExchange.SetBounds(ThreeBox + 8, 8, TwoBox, 0)
        txtNumber.SetBounds(ThreeBox + TwoBox + 8, 8, FourBox, 0)
      End If

    End Sub

  End Class
